package com.gaoxin.api.service.eduservice;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gaoxin.api.dao.edudao.QueryStuScoreDao;
import com.gaoxin.api.entity.eduentity.Dept;
import com.gaoxin.api.entity.eduentity.StuScoreEntity;
import com.gaoxin.api.entity.statisentity.Course;

/**
 * 查询学生成绩接口-业务层
 *
 * @author fanyue
 * @email 859485490@qq.com
 * @date 2018-07-12 15:21
 */
@Service
public class QueryStuScoreService {
	Logger log = Logger.getLogger("~~QueryStuScoreService~~~~~~~~");
	@Autowired
	private QueryStuScoreDao queryStuScoreDao;

	/**
	 * 查询学生成绩
	 * 
	 * @param stuNumber
	 * @return StuInfoEntity
	 * @throws Exception
	 */
	public List<StuScoreEntity> queryStuScore(String stuCode, String semester) throws Exception {
		log.info("查询学生成绩开始。。。" + stuCode);
		List<StuScoreEntity> list = new ArrayList<>();
		try {
			String year = semester.substring(0, 4);
			String term = semester.substring(5, 6);
			list = queryStuScoreDao.queryStuScore(stuCode, year, term);
			System.out.println("***********" + list.toString());
		} catch (Exception e) {
			log.warning("查询学生成绩异常。。。");
			e.printStackTrace();
		}
		return list;
	}
	/**
	 * 查询所有的二级院系
	 * @return
	 */
	public List<Dept> queryAllDept()throws Exception{
		return queryStuScoreDao.queryAllDept();
	}
	/**
	 * 更具院系查询所属专业
	 * @param deptId
	 * @return
	 */
	public Dept queryMajorByDeptId(String deptId)throws Exception{
		return queryStuScoreDao.queryMajorByDeptId(deptId);
	}
	/**
	 * 查询某门课程下所有学生的成绩
	 * @param courseId
	 * @param year
	 * @param term
	 * @return
	 */
	public Course queryCourseScores (String courseId,String year,String term)throws Exception{
		return queryStuScoreDao.queryCourseScores(courseId, year, term);
	}
	/**
	 * 
	 */
	public List<StuScoreEntity> queryScores(String year,String term,String deptId,String grade,String stuNumber,String courseId)throws Exception {
		return queryStuScoreDao.queryScores(year, term, deptId, grade,stuNumber,courseId);
	}
	/**
	 * 查询缓考免考的学生记录
	 * @return
	 */
	public List<StuScoreEntity> queryNoExam(String year,String term,String deptId,String grade,String stuNumber,String courseId){
		return queryStuScoreDao.queryNoExam(year, term, deptId, grade, stuNumber,courseId);
	}
}
